class R<T> {
  code: number;
  message: string;
  data?: T;
  constructor(options: { code: number; message: string; data?: any }) {
    this.code = options.code;
    this.message = options.message;
    this.data = options?.data;
  }
  static ok<T>(data?: T): R<T> {
    return new R({
      code: 200,
      message: '请求成功！',
      data,
    });
  }
  static error(message: string): R<any> {
    return new R({
      code: 500,
      message,
    });
  }
}

export default R;
